<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input class="like" type="checkbox">足球
    <input class="like" type="checkbox">篮球
    <input class="like" type="checkbox">排球
    <input class="like" type="checkbox">乒乓球<br>
    <input id="all" type="checkbox">全选</input>
    <script>
        var all = document.querySelector("#all");
        var inputs = document.querySelectorAll(".like")
        all.onclick = function(){
            for(var i =0;i<inputs.length;i++){
                inputs[i].checked = all.checked;
            }
        }
        for(var i =0 ;i<inputs.length;i++){
            inputs[i].onclick = function () {
                var flag = true;
                for(var i=0;i<inputs.length;i++){
                    if(inputs[i].checked == false){
                        flag = false;
                        break;
                    }

                }
                all.checked = flag;
            }
        }
    </script>
</body>
</html>